teEstimate <- function(dat, id.var = "id", covs, exact.v, n.iter = 1, outcomes, assg = "sb", ...){
  store.assg <- matrix(NA, n.iter, nrow(dat))

  for(iii in 1:n.iter){
    sb1 <- seqblock1(id.vars = id.var, id.vals = dat[1, id.var], exact.vars = exact.v, exact.vals = dat[1, exact.v], covar.vars = covs, covar.vals = dat[1, covs], tr.names = c("anagrams", "memory"), assg.prob.kfac = 5, file.name = "~/Desktop/sbout.RData", verbose = FALSE)
  
    for(n.idx in 2:nrow(dat)){
      sb2k <- seqblock2k(object = "~/Desktop/sbout.RData", id.vals = dat[n.idx, id.var], exact.vals = dat[n.idx, exact.v], covar.vals = dat[n.idx, covs], file.name = "~/Desktop/sbout.RData", verbose = FALSE)
    }
  
  store.assg[iii, ] <- sb2k$orig$Tr
  }

  ests.dm.mat <- ests.aipw.mat <- rmse.aipw.mat <- matrix(NA, n.iter, length(outcomes))
  colnames(ests.dm.mat) <- colnames(ests.aipw.mat) <- colnames(rmse.aipw.mat) <- outcomes
  for(sb.idx in 1:n.iter){
    if(sb.idx %% 50 == 0){
      print(paste("Iteration ", sb.idx, sep=""))
    }
    tmp.dat <- dat
    tmp.dat$condition <- store.assg[sb.idx, ]
    dm.mat <- diff.mean(outcomes, tmp.dat)
    ests.dm.mat[sb.idx, ] <- dm.mat[ ,1]
    aipw.vec <- array(NA, length(outcomes))
    for(i in 1:length(outcomes)){
      calc.aipw.obj <- calcAIPWest(outcomes[i], tmp.dat, assg = assg, ...)
      aipw.vec[i] <- calc.aipw.obj$ate.aipw
      rmse.aipw.mat[sb.idx, i] <- calc.aipw.obj$rmse
    }
    ests.aipw.mat[sb.idx, ] <- aipw.vec
    
  }
  return(list(ests.dm.mat = ests.dm.mat, ests.aipw.mat = ests.aipw.mat, rmse.aipw.mat = rmse.aipw.mat))
}
